fragment CiNeeds on JobNeedUnion {
  ...CiBuildNeedFields
  ...CiJobNeedFields
}

fragment CiBuildNeedFields on CiBuildNeed {
  id
  name
}

fragment CiJobNeedFields on CiJob {
  id
  name
}

fragment LinkedPipelineData on Pipeline {
  __typename
  id
  iid
  path
  cancelable
  retryable
  userPermissions {
    updatePipeline
  }
  status: detailedStatus {
    __typename
    id
    group
    label
    icon
  }
  sourceJob {
    __typename
    id
    name
    retried
  }
  project {
    __typename
    id
    name
    fullPath
  }
}

query getPipelineDetails($projectPath: ID!, $iid: ID!) {
  project(fullPath: $projectPath) {
    __typename
    id
    pipeline(iid: $iid) {
      __typename
      id
      iid
      complete
      usesNeeds
      userPermissions {
        updatePipeline
      }
      downstream {
        __typename
        nodes {
          ...LinkedPipelineData
        }
      }
      upstream {
        ...LinkedPipelineData
      }
      stages {
        __typename
        nodes {
          __typename
          id
          name
          status: detailedStatus {
            __typename
            id
            action {
              __typename
              id
              icon
              path
              title
            }
          }
          groups {
            __typename
            nodes {
              __typename
              id
              status: detailedStatus {
                __typename
                id
                label
                group
                icon
              }
              name
              size
              jobs {
                __typename
                nodes {
                  __typename
                  id
                  name
                  kind
                  scheduledAt
                  needs {
                    __typename
                    nodes {
                      __typename
                      id
                      name
                    }
                  }
                  previousStageJobsOrNeeds {
                    __typename
                    nodes {
                      ...CiNeeds
                    }
                  }
                  status: detailedStatus {
                    __typename
                    id
                    icon
                    tooltip
                    hasDetails
                    detailsPath
                    group
                    label
                    action {
                      __typename
                      id
                      buttonTitle
                      icon
                      path
                      title
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
